package com.esri.core.tasks.tilecache;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.io.handler.n;
import com.esri.core.internal.tasks.PollingHelper;
import com.esri.core.io.UserCredentials;
import com.esri.core.tasks.ags.geoprocessing.GPJobResource;
import java.util.Map;
import org.codehaus.jackson.JsonParser;

/* loaded from: classes.dex */
final class TileCacheLayerStatusPollHelper implements PollingHelper.StatusCallback<TileCacheJobResource, GPJobResource.JobStatus> {
    private String _jobId;

    public TileCacheLayerStatusPollHelper(String str) {
        this._jobId = str;
    }

    /* JADX WARN: Can't rename method to resolve collision */
    @Override // com.esri.core.internal.tasks.PollingHelper.StatusCallback
    public TileCacheJobResource getStatusObject(String str, UserCredentials userCredentials) throws Exception {
        return checkJobStatus(str, this._jobId, userCredentials);
    }

    @Override // com.esri.core.internal.tasks.PollingHelper.StatusCallback
    public GPJobResource.JobStatus getStatus(TileCacheJobResource tileCacheJobResource) {
        return tileCacheJobResource.getJobStatus();
    }

    @Override // com.esri.core.internal.tasks.PollingHelper.StatusCallback
    public boolean isComplete(GPJobResource.JobStatus jobStatus) {
        return GPJobResource.JobStatus.CANCELLED.equals(jobStatus) || GPJobResource.JobStatus.DELETED.equals(jobStatus) || GPJobResource.JobStatus.FAILED.equals(jobStatus) || GPJobResource.JobStatus.SUCCEEDED.equals(jobStatus) || GPJobResource.JobStatus.TIMED_OUT.equals(jobStatus);
    }

    private TileCacheJobResource checkJobStatus(String str, String str2, UserCredentials userCredentials) throws Exception {
        JsonParser a = h.a(str + "/jobs/" + str2, (Map<String, String>) null, n.a(str, userCredentials));
        TileCacheJobResource fromJson = TileCacheJobResource.fromJson(a, str, userCredentials);
        a.close();
        return fromJson;
    }

    /* JADX WARN: Can't rename method to resolve collision */
    @Override // com.esri.core.internal.tasks.PollingHelper.StatusCallback
    public TileCacheJobResource determineFailedStatus(Exception exc) {
        return new TileCacheJobResource(exc);
    }
}
